<?php 
header("content-type:text/html;charset=utf-8");
$redis = new Redis();
$redis->connect("127.0.0.1","6379");
$pdo = new PDO("mysql:host=127.0.0.1;dbname=lx","root","root");
$tel = $_POST['tel'];
$code = $_POST['code'];
$name = $_POST['name'];
$pwd = $_POST['pwd'];
$time = date("Y-m-d H:i:s");
$rediscode = $redis->get("code".$tel);
if ($rediscode) {
	if ($rediscode==$code) {
		$sql = "insert into redis values('','$name','$pwd','$tel',1,'$time')";
		$res = $pdo->exec($sql);
		if ($res) {
			$data = array('code'=>0,'msg'=>"注册成功");
		}else{
			$data = array('code'=>1,'msg'=>"注册失败");
		}
	}else{
		$data = array('code'=>2,'msg'=>"验证码输入有误");
	}
}else{
	$data = array('code'=>3,'msg'=>"验证码已失效");
}
echo json_encode($data);







 ?>